package v3.object.command.list;

import java.util.Map;

import text.TextUtil;
import v3.object.STcfg;
import v3.object.command.aCommand;
import v3.object.command.iCommand;
import v3.object.command.servoCommand.ComputerMessage;
import v3.object.ship.Ship;
import v3.object.space.Universe;

public class Shield extends aCommand
{

	public Shield()
	{
		super();
		commandName="SHIELD";
	}
	
	@Override
	public void getHelp(Ship ship)
	{
		String help = "SHIELD  \n\n" + "Turn ON or OFF Ship Shield" + "\nTime Cost "+ship.getTimeConsume((this.getClass()))+"\n" + "Energy Cost " +ship.getEnergyConsume((this.getClass()))+" times distance";
		help = TextUtil.formatHelp(help);
		System.out.println(help);
	}

	@Override
	protected boolean isCommandAccetable(STcfg cfg, Universe universe, Ship ship, Map<String, iCommand> commands, String[] input)
	{
		return true;
	}

	@Override
	protected double calculateEnergy(STcfg cfg, Universe universe, Ship ship, Map<String, iCommand> commands, String[] input)
	{
		return ship.getEnergyConsume((this.getClass()));
	}

	@Override
	protected double calculateTime(STcfg cfg, Universe universe, Ship ship, Map<String, iCommand> commands, String[] input)
	{
		return ship.getTimeConsume((this.getClass()));
	}

	@Override
	protected void checkInput(String[] input) throws Exception
	{
		
	}

	@Override
	protected boolean realExecute(STcfg cfg, Universe universe, Ship ship, Map<String, iCommand> commands, String[] input)
	{
		ship.setShieldON(!ship.isShieldON());
		iCommand c = new ShortSensor();
		c.execute(cfg, universe, ship, commands, input);
		
		c = new ComputerMessage("- SHILED are * "+(ship.isShieldON()? "ON": "OFF")+" *");
		c.execute(cfg, universe, ship, commands, input);
		
		
		return true;
	}

	@Override
	protected boolean confirmCommand(STcfg cfg, Universe universe, Ship ship, Map<String, iCommand> commands, String[] input)
	{
		return true;
	}

}
